package com.fenghongzhang.day013;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import java.util.ArrayList;
import java.util.List;


/**
 * A simple {@link Fragment} subclass.
 */
public class OneFragment extends Fragment {
    private Button btn;

    public OneFragment() {
        // Required empty public constructor
    }


    public  interface MyListener {
        void sendInt(int i);
    }

    private MyListener myListener;
    private ViewPager fgVp;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment

        myListener = (MyListener) getActivity();


        View inflate = inflater.inflate(R.layout.fragment_one, container, false);
        btn = (Button) inflate.findViewById(R.id.btn);
        fgVp = (ViewPager) inflate.findViewById(R.id.fg_vp);
//
//        List<Fragment> list = new ArrayList<>();
//        list.add(new ThreeFragment());
//        list.add(new FourFragment());
//
//        FragmentAdapter fragmentAdapter = new FragmentAdapter(getChildFragmentManager(), list);
//
//        fgVp.setAdapter(fragmentAdapter);




        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               myListener.sendInt(1);
            }
        });

        return inflate;
    }
}
